package com.my.goodsmanage.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.my.goodsmanage.dao.ThingMapper;
import com.my.goodsmanage.entity.Goods;
import com.my.goodsmanage.entity.Thing;
import com.my.goodsmanage.service.ThingService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

/**
 * @author 徐佳辉
 * @date 2020/10/7 14:39
 */
@Service
public class ThingServiceImpl extends ServiceImpl<ThingMapper, Thing> implements ThingService {


    @Override
    public void pageListCondition(Page<Thing> thingPage, int userId, String name) {
        if (userId < 0) {
            baseMapper.selectPage(thingPage, null);
            return;
        }
        QueryWrapper<Thing> wrapper = new QueryWrapper<>();
        wrapper.eq("user_id", userId);
        if (StringUtils.isEmpty(name)) {
            baseMapper.selectPage(thingPage, wrapper);
        } else {
            wrapper.like("thing", name);
            baseMapper.selectPage(thingPage, wrapper);
        }


        return;
    }
}
